package com.example.yichuangyun.mvvm.ui.activity;

import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.yichuangyun.R;
import com.example.yichuangyun.config.Constant;
import com.example.yichuangyun.databinding.ActivityPatentBinding;
import com.example.yichuangyun.model.company.IntellectualPropertyDataModel;
import com.example.yichuangyun.mvvm.base.BaseActivity;
import com.example.yichuangyun.mvvm.ui.activity.view.PatentViewModel;
import com.example.yichuangyun.mvvm.ui.adapter.PatentAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 专利
 */
public class PatentActivity extends BaseActivity<ActivityPatentBinding, PatentViewModel> {

    private int page = 1;
    private List<IntellectualPropertyDataModel.IntellectualPropertyModel> data = new ArrayList<>();
    private PatentAdapter adapter;

    @Override
    protected PatentViewModel bindModel() {
        return getViewModel(this, PatentViewModel.class);
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initData() {
        initTitleBar(getString(R.string.zl));
        Bundle bundle = getIntent().getExtras();
        if (null != bundle) {
            String eid = bundle.getString(Constant.eidKey);
            viewModel.getIntellectualProperty(eid);
        }
        adapter = new PatentAdapter(context, data);
        binding.recyclerView.setAdapter(adapter);
    }

    @Override
    protected void initClick() {
        viewModel.mutableLiveData.observe(this, intellectualPropertyModels -> {
            data = intellectualPropertyModels.subList(0, 10);
            adapter.submitList(data);
        });
    }
}